package com.paradogs.gs.modules.world.base.unit;

import com.paradogs.gs.db.World;
import com.paradogs.gs.misc._NetMgr;
import com.paradogs.gs.modules.GameObject;
import com.paradogs.gs.modules.WorldObject;
import com.paradogs.gs.modules.WorldSyncData;
import com.paradogs.gs.modules.role.RoleMgr;
import com.paradogs.gs.modules.world.WorldMgr;
import lombok.Getter;

/**
 * @author: yumi
 * @date: 2025/4/21  16:12
 * @Description: TODO
 */
public class WorldPlayer extends WorldObject {

    public WorldPlayer(GameObject obj) {
        if (obj == null) return;
        WorldMgr mgr = obj.getMgr(WorldMgr.class);
        if (mgr == null) return;
        setGameObject(obj);
        World data = mgr.__get__();
        load(obj.getId(), data.getWorldId(), data.getX(), data.getY(), data.getHp(), 777, data.getMp(), 888, UnitType.PLAYER);
    }

    @Override
    public WorldSyncData toSyncData() {
        return new WorldSyncData(
                getId(),
                getGameObject().getMgr(RoleMgr.class).__raw__().getNickName(),
                UnitType.PLAYER,
                getGameObject().getMgr(RoleMgr.class).__raw__().getLevel(),
                getHp(),
                getMaxHp(),
                getMp(),
                getMaxMp(),
                "描述1",
                "描述2"
        );
    }

    public void attack(Long targetId) {
        WorldObject target = curNode().getObjectMap().get(targetId);
        if (target == null) {
            return;
        }
        target.onBeHurt(this);
    }

    @Override
    public void pickUp(WorldObject target) {
        if (target == null) {
            return;
        }
        target.BePickUp(this);
    }

    @Override
    public boolean canPickUp() {
        return true;
    }

}
